package com.artisan.provider.controller;

import com.artisan.provider.covtransformation.CovCommentMessageTransformation;
import com.artisan.provider.domain.ZgCommentMessage;
import com.artisan.provider.dto.ZgCommentMessageDto;
import com.artisan.provider.service.ZgCommentMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class ZgCommentMessageController {

    @Autowired
    private ZgCommentMessageService zgCommentMessageService;

    /**
     * 查询所有
     * @param page
     * @param limit
     * @param zgCommentMessage
     * @return
     */
    @PostMapping(value = "/zg/comment/messgae/find/all/{page}/{limit}")
    public List<ZgCommentMessage> zgCouponMessageFindAll(@PathVariable(required = false)int page,
                                                         @PathVariable(required = false) int limit,
                                                         @RequestBody(required = false) ZgCommentMessage zgCommentMessage
                                  ){

        return zgCommentMessageService.findAll(page,limit,zgCommentMessage);
    }

    /**
     * 新增业务
     * @param zgCommentMessageDto
     * @return
     */
    @PostMapping(value = "/zg/comment/messgae/add")
    public int zgCouponMessageAdd(@RequestBody(required = false) ZgCommentMessageDto zgCommentMessageDto){

        ZgCommentMessage zgCommentMessage = CovCommentMessageTransformation.INSTANCE.zgCommentMessage(zgCommentMessageDto);

        return zgCommentMessageService.add(zgCommentMessage);
    }

    /**
     * 修改业务
     * @param zgCommentMessageDto
     * @return
     */
    @PutMapping(value = "/zg/comment/message/update")
    public int zgCommentMessageUpdate(@RequestBody(required = false) ZgCommentMessageDto zgCommentMessageDto){

        ZgCommentMessage zgCommentMessage = CovCommentMessageTransformation.INSTANCE.zgCommentMessage(zgCommentMessageDto);

        return zgCommentMessageService.update(zgCommentMessage);
    }

    /**
     * 根据id删除
     * @param id
     * @return
     */
    @DeleteMapping(value = "/zg/comment/message/{id}")
    public int zgCommentMessageDelete(@PathVariable(value = "id") int id){

        return zgCommentMessageService.delete(id);
    }

}
